package com.gtq.uhome.service.serviceImpl;

import com.gtq.uhome.mapper.DistributionPersonalCenterMapper;
import com.gtq.uhome.service.DistributionPersonalCenterService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 配送员个人中心实现类
 */
@Service
public class DistributionPersonalCenterServiceImpl implements DistributionPersonalCenterService {

    @Resource
    DistributionPersonalCenterMapper distributionPersonalCenterMapper;
    /**
     * 配送员信息展示
     * @return 返回配送员信息
     */
    @Override
    public Map CourierInfo(Integer courierId) {
        //查询派送员姓名
        String name = distributionPersonalCenterMapper.selectUserName(courierId);
        //查询派送员派单总数量
        Integer deliveredCountNumber = distributionPersonalCenterMapper.selectDelivered(courierId);
        //查询派送员待取货数量
        Integer toBeDeliveredNumber = distributionPersonalCenterMapper.selectToBeDelivered(courierId);
        //查询配送员待送货数量
        Integer  inProgressNumber= distributionPersonalCenterMapper.selectDeliveryInProgress(courierId);
        //查询配送员配送失败数量
        Integer failNumber = distributionPersonalCenterMapper.selectDeliveredFail(courierId);
        //查询配送员配送成功数量
        Integer successNumber = distributionPersonalCenterMapper.selectDeliveredSuccess(courierId);
        //查询客服电话
        String sitePhoneNumber = distributionPersonalCenterMapper.selectSitePhoneNumber();
        //声明一个map集合
        Map<String,Object> courierInfo=new HashMap<>();
        courierInfo.put("name",name);
        courierInfo.put("deliveredCountNumber",deliveredCountNumber);
        courierInfo.put("toBeDeliveredNumber",toBeDeliveredNumber);
        courierInfo.put("inProgressNumber",inProgressNumber);
        courierInfo.put("failNumber",failNumber);
        courierInfo.put("successNumber",successNumber);
        courierInfo.put("sitePhoneNumber",sitePhoneNumber);
        if (courierInfo!=null){
            return courierInfo;
        }else {
            return null;
        }

    }

    /**
     * 配送员消息中心
     * @return 返回配送员所有订单消息
     */
    @Override
    public List<String> CourierMsg(Integer courierId) {
        List<String> strings = distributionPersonalCenterMapper.selectCourierMsg(courierId);
        return strings;
    }


}
